SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE Procedure [dbo].[TvShow_Get_SeasonList]
@TvId INT
AS


SELECT DISTINCT s.SeasonId, Season, IsWatched, MIN(e.airdate) AS StartDate, MAX(e.airdate) AS EndDate
from tvshow_seasons s
left join tvshow_episodes e on s.SeasonId = e.SeasonId
Where s.TvId = @TvId
Group By S.SeasonId, season, IsWatched
Order By Season ASC
GO
